package com.sanyang.pda.ui.scandemo;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.google.gson.Gson;
import com.sanyang.pda.adapter.ScanDemoAdapter;
import com.sanyang.pda.bean.ScanBean;
import com.sanyang.pda.bean.ScanDemoBean;
import com.sanyang.pda.view.ScanButView;
import com.wangshen.base.app.AppActivityKey;
import com.wangshen.base.ui.mvp.base.ui.BaseActivity;
import com.wangshen.projectbase.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@Route(path = AppActivityKey.SCANDEMOACIVITY)
public class ScanDemoAcivity extends BaseActivity {
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.title)
    FrameLayout title;
    @BindView(R.id.tv_job_location)
    TextView tvJobLocation;
    @BindView(R.id.tv_goods_tray)
    TextView tvGoodsTray;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_xuehao)
    TextView tvXuehao;
    @BindView(R.id.tv_xueyuan)
    TextView tvXueyuan;
    @BindView(R.id.rv_list)
    RecyclerView rvList;
    @BindView(R.id.scan)
    ScanButView scan;

    @Override
    public int getView() {
        return R.layout.activity_scan_demo;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initLinsenterner() {
        scan.setScanCallBack(new ScanButView.ScanCallBack() {
            @Override
            public void callBack(ScanBean scanBean) {
                //Toast.makeText(mContext, scanBean.getCode(), Toast.LENGTH_SHORT).show();
                ScanDemoBean scanDemoBean=new Gson().fromJson(scanBean.getCode(), ScanDemoBean.class);
                if (scanDemoBean != null){
                    tvJobLocation.setText(scanDemoBean.getQrCode());
                    if (scanDemoBean.getType().equals("10")){
                        tvGoodsTray.setText("入库");
                    }else {
                        tvGoodsTray.setText("出库");
                    }
                    tvName.setText(scanDemoBean.getStudentName());
                    tvXuehao.setText(scanDemoBean.getStudentId()+"");
                    tvXueyuan.setText(scanDemoBean.getCollege());
                    ScanDemoAdapter adapter=new ScanDemoAdapter(R.layout.item_scan_demo,scanDemoBean.getInfo());
                    rvList.setAdapter(adapter);
                }
            }
        });
    }

    @Override
    public void getData() {

    }


    @OnClick(R.id.iv_back)
    public void onViewClicked() {
        finish();
    }
}
